﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;

public partial class AdminManage_Edit_BBEdit : System.Web.UI.Page
{

    public string bbid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        bbid = Request["bbid"];
        bind();
    }


    private void bind()
    {
        BBInfo bbquery = new BBInfo();
        int BBID = Convert.ToInt32(bbid);
        DataSet ds = bbquery.SelectInfoByID(BBID);
        DataRowView dv = ds.Tables[0].DefaultView[0];

        
        
      
        ZL_FILE_ID.Text = Convert.ToString(dv.Row["ZL_FILE_ID"]);


        BB_NAME.Text = Convert.ToString(dv.Row["BB_NAME"]);
        BB_CODE.Text = Convert.ToString(dv.Row["BB_CODE"]);
        PM_PATH_NAME.Text = Convert.ToString(dv.Row["PM_PATH_NAME"]);
        PM_PATH_NUM.Text = Convert.ToString(dv.Row["PM_PATH_NUM"]);



        GEO_ATT_NUM.Text = Convert.ToString(dv.Row["GEO_ATT_NUM"]);
        CY_POS.Text = Convert.ToString(dv.Row["CY_POS"]);
        QY_METHOD.Text = Convert.ToString(dv.Row["QY_METHOD"]);//行政区划
        CY_LEVEL.Text = Convert.ToString(dv.Row["CY_LEVEL"]);

        CJ_PEOPLE.Text = Convert.ToString(dv.Row["CJ_PEOPLE"]);
        CJ_DATE.Text = Convert.ToString(dv.Row["CJ_DATE"]);

        BB_LON_D.Text = Convert.ToString(dv.Row["BB_LON"]).Substring(0, 3);
        BB_LON_F.Text = Convert.ToString(dv.Row["BB_LON"]).Substring(3, 2);
        BB_LON_M.Text = Convert.ToString(dv.Row["BB_LON"]).Substring(5);


        BB_LAT_D.Text = Convert.ToString(dv.Row["BB_LAT"]).Substring(0, 2);
        BB_LAT_F.Text = Convert.ToString(dv.Row["BB_LAT"]).Substring(2, 2);
        BB_LAT_M.Text = Convert.ToString(dv.Row["BB_LAT"]).Substring(4);

        BB_STYLE.Text = Convert.ToString(dv.Row["BB_STYLE"]);
        STYLE_CODE.Text = Convert.ToString(dv.Row["STYLE_CODE"]);

        BP_ID.Text = Convert.ToString(dv.Row["BP_ID"]);



        OUT_NAME.Text = Convert.ToString(dv.Row["OUT_NAME"]);
        INNAR_NAME.Text = Convert.ToString(dv.Row["INNAR_NAME"]);
        IMAGE.Text = Convert.ToString(dv.Row["IMAGE"]);
        REMARK.InnerText = Convert.ToString(dv.Row["REMARK"]);
         


        //从著录表中读取title
        ZLInfo ZLFILEID = new ZLInfo();
        ZL_TBL zl = ZLFILEID.SelectZLInfoByID(dv.Row["ZL_FILE_ID"].ToString());
        TITLE_.Text = zl.O_TITLE;
        FileTitle.Text = zl.O_TITLE;


    }


    protected void submit_Click(object sender, EventArgs e)
    {
        BB_INFO_TBL bbInfo = new BB_INFO_TBL();
        BBInfo kc_in = new BBInfo();

        bbInfo.O_ZL_FILE_ID = Request.Form["ZL_FILE_ID"];
        bbInfo.O_BB_NAME = Request.Form["BB_NAME"];
        bbInfo.O_BB_CODE = Request.Form["BB_CODE"];


        bbInfo.O_PM_PATH_NAME = Request.Form["PM_PATH_NAME"];
        bbInfo.O_PM_PATH_NUM = Request.Form["PM_PATH_NUM"];
        bbInfo.O_GEO_ATT_NUM = Request.Form["GEO_ATT_NUM"];
        bbInfo.O_CY_POS = Request.Form["CY_POS"];





        bbInfo.O_QY_METHOD = Request.Form["QY_METHOD"];
        bbInfo.O_CY_LEVEL = Request.Form["CY_LEVEL"];
        bbInfo.O_CJ_PEOPLE = Request.Form["CJ_PEOPLE"];

        bbInfo.O_CJ_DATE = Request.Form["CJ_DATE"];

        bbInfo.O_BB_LAT = int.Parse((Request.Form["BB_LAT_D"] + Request.Form["BB_LAT_F"] + Request.Form["BB_LAT_M"]));
        bbInfo.O_BB_LON = int.Parse((Request.Form["BB_LON_D"] + Request.Form["BB_LON_F"] + Request.Form["BB_LON_M"]));

        bbInfo.O_BB_STYLE = Request.Form["BB_STYLE"];

        bbInfo.O_STYLE_CODE = Request.Form["STYLE_CODE"];
        bbInfo.O_BP_ID = Request.Form["BP_ID"];
        bbInfo.O_OUT_NAME = Request.Form["OUT_NAME"];
        bbInfo.O_INNAR_NAME = Request.Form["INNAR_NAME"];

        //pm_info.O_IMAGE = Request.Form["IMAGE"];

        bbInfo.O_REMARK = this.REMARK.InnerText;


        bbInfo.O_ID = int.Parse(bbid);

        if (kc_in.UpdatebbInfo(bbInfo) == 1)
        {
            bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/BBManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/BBManage.aspx'</script>");
        }
    }
}